package com.bkbw.live.common.fsm;

public class GameStateMachine {
	protected GameState state;
	public void setState(GameState state) 
	{
		if (this.state != null && this.state.onExit != null) {
			this.state.onExit.action();
		}
		this.state = state;
		if (this.state != null && this.state.onEnter != null) {
			this.state.onEnter.action();
		}
	}
	
	public GameState getState()
	{
		return state;
	}
	
	public GameStateMachine()
	{
		
	}
	
	public void update(float dt) 
	{
		if (this.state != null && this.state.onUpdate != null) {
			this.state.onUpdate.action(dt);
		}
	}
	
	public void handle(Object sender, Object param) 
	{
		if (this.state != null && this.state.onMessage != null) {
			this.state.onMessage.handle(sender, param);
			
		}
	}
	
}
